﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameRoot : MonoBehaviour
{
    
    // Start is called before the first frame update
    void Start()
    {
        Singleton<ContentManager>.GetInstance().Push(new MainPanelContent());
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnApplicationQuit()
    {
        // 软件关闭时，断开与客户端的所有连接
        foreach (Member mem in Singleton<MemberManager>.GetInstance().Members)
        {
            if(mem.Client != null && mem.Client.Connected)
            {
                if (mem.Client.GetStream() != null)
                    mem.Client.GetStream().Close();
                mem.BaseClient.TcpClient.Close();
            }
        }
        // 销毁服务器
        Singleton<TcpServer>.GetInstance().Destory();
    }
}
